{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c43a8050",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[4]\n",
      "[[255]]\n"
     ]
    }
   ],
   "source": [
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "x = np.uint8([250])\n",
    "y = np.uint8([10])\n",
    "#对256取模 %256\n",
    "print(x+y)\n",
    "#在255截断\n",
    "print(cv.add(x,y))\n",
    "\n",
    "shape = (200,200,1)\n",
    "img1 = np.ones(shape, np.uint8)*250\n",
    "img2 = np.ones(shape, np.uint8)*10\n",
    "\n",
    "#第一种变黑色\n",
    "cv.imshow(\"pic\", img1+img2)\n",
    "cv.waitKey(0)\n",
    "#第二种还是白色\n",
    "cv.imshow(\"pic\", cv.add(img1,img2))\n",
    "cv.waitKey(0)\n",
    "\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bf29d042",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
